package com.itheima.reggie.common;

import lombok.Data;

import java.util.*;

/**
 * @Author 669
 * @CreateDate 2023/2/26 14:47
 * @Version 1.0
 * 通用返回结果
 */
@Data
public class R<T> {
    private Integer code;
    private String msg;
    private T data;
    private Map map = new HashMap();


    //返回成功的方法
    public static <T> R<T> success(T object){
        R<T> r = new R<>();
        r.data=object;
        r.code=1;
        return r;
    }
    //失败的方法
    public static <T> R<T> error(String msg){
        R<T> r = new R<>();
        r.msg=msg;
        r.code=0;
        return r;
    }
    public R<T> add(String key,Object value){
        this.map.put(key, value);
        return this;
    }


}
